/**
 * k3相关页面绑定效果， 方法请求不在此文件中
 */
// 切换同系列彩种
$('.tag_choose_other').on('click', '', function (){
	if($('.fix').is(':hidden')){
		$('.fix').show();
	}else{
		$('.fix').hide();
	}
})

// 切换彩种玩法
$('.tag_bet_play').on('click', '', function (){
	if($('.tag_bet_play_items').is(':hidden')){
		$('.tag_bet_play_items').show();
	}else{
		$('.tag_bet_play_items').hide();
	}
})

$('.tag_bet_play_items li').on('click', '', function (){
	$('.tag_k3_play').removeClass('checked');
	$(this).addClass('checked');
	$('.tag_bet_play_items').hide();
	k3_play_controller($(this).attr('id'));
})

//当前最大赔率
var maxOdds    = 0;
// 投注内容
var choice_str = '';
$('.MethodWrap').on('click', '.tag_play_X li', function (){
	// 提取数据
	var tag_str    = $(this).html();
	var c_odds     = '';
	var c_str      = '';
	// 检查获取数据的方式
	var check_play = tag_str.indexOf('font');
	if(check_play >= 0){
		c_odds     = parseInt(tag_str.match(/<font.*>(.+)<\/font>/)[1] * 100);
		c_str      = $.trim(tag_str.replace(/<p.*<\/p>/i,""));
	}else{
		c_odds     = parseInt(tag_str.match(/<p.*>(.+)<\/p>/)[1] * 100);
		c_str      = $.trim(tag_str.replace(/<p.*<\/p>/i,""));
	}
	
	if($(this).attr('class') == 'checked'){
		$(this).removeClass('checked');
		betting.splice($.inArray(c_str, betting), 1);
		oddsArr.splice($.inArray(c_odds, oddsArr), 1);
	}else{
		$(this).addClass('checked');
		betting.push(c_str);
		oddsArr.push(c_odds);
	}
	
	// 二同号单选的方式有点不一样的情况，比如选点亮了22选项，那再点击2选项时，22要失效。同数号仅存一个
	var check_info    = check_bet_type(choice_k3_play);
	// 投注数
	var betting_number = betting.length;
	if(check_info){
		switch(choice_k3_play){
			case 'item_ethdx':
				// 需要取消dom_id选项的预投注状态
				$('#' + check_info.dom_id).removeClass('checked');
				break;
			case 'item_ethfx':
				break;
		}
		betting_number = check_info.bettint_number;
	}
	
	choice_str = '';
	if(betting.length > 0){
		for(var i = 0; i < betting.length; i++){
			if(isNaN(parseInt(betting[i]))){
				choice_str  = betting[i] + '&nbsp;' + choice_str;
			}else{
				choice_str += betting[i] + '&nbsp;';
			}
		}
		
		for(var j = 0; j < oddsArr.length; j++){
			if(parseInt(oddsArr[j]) > maxOdds){
				maxOdds = parseInt(oddsArr[j]);
			}
		}
		$('.tag_betting_maxodds').html(parseFloat(maxOdds / 100));
		$('#choice').html(choice_str);
		$('.tag_betting_count').html('共<span class="tag_betting_number">' + betting_number + '</span>注');
		$('.tag_betting_content').show();
	}else{
		$('.tag_betting_content').hide();
	}
})

$('.tag_betting_pay_everyone').on('change', '', function (){
	if($(this).val()){
		$('.tag_betting_tips').hide();
		$('.tag_betting_tips_maxodds').show();
	}else{
		$('.tag_betting_tips').show();
		$('.tag_betting_tips_maxodds').hide();
	}
})

$('.tag_betting_ord').on('click', '', function (){
	if($.isEmptyObject(resData.data.lotting)){
		layer_msg('温馨提示', '投注暂未开始');
		return;
	}
	if(betting.length == 0){
		layer_msg('错误提示', '请至少选择一注号码投注', '');
		return;
	}
	if(parseInt($('.tag_betting_number').html()) == 0){
		layer_msg('错误提示', '请至少选择一注号码投注', '');
		return;
	}
	if(!$('.tag_betting_pay_everyone').val()){
		layer_msg('错误提示', '请设置投注金额', '');
		return;
	}
	if(parseInt($('.tag_betting_pay_everyone').val() * 100) <= 0){
		layer_msg('错误提示', '请设置投注金额', '');
		return;
	}
	// 展示投注信息
	var lott_notice = '';
	lott_notice    += $('#choice_play').val() + ':' + resData.data.lotting.period + '期<br/>';
	lott_notice    += '投注金额：<span style="color:red">' + parseFloat($('.tag_betting_number').html() * $('.tag_betting_pay_everyone').val() ) + '元</span><br/>';
	lott_notice    += '投注内容：' + choice_str;
	layer_msg('温馨提示', lott_notice, 'submit');
})

$('.tag_clear_betting').on('click', '', function (){
	clear_betting();
})

setTimeout("getLastPerOpen()", 1000*2);